package com.coderlin.service.role;

import com.coderlin.dao.BaseDao;
import com.coderlin.dao.role.RoleDao;
import com.coderlin.dao.role.RoleDaoImpl;
import com.coderlin.pojo.Role;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

/**
 * <Description> <br>
 *
 * @author Coder_Lin<br>
 * @version 1.0<br>
 * @taskId: <br>
 * @createDate 2021/03/14 19:47 <br>
 * @see com.coderlin.servlet.user <br>
 */
public class RoleServiceImpl implements RoleService {

    private RoleDao roleDao = null;

    public RoleServiceImpl(){
        roleDao = new RoleDaoImpl();
    }

    @Override
    public List<Role> getRoleList() {
        Connection connection = null;
        List<Role> list = null;
        try {
            connection = BaseDao.getConnection();
            list = roleDao.getRoleList(connection);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }finally {
            BaseDao.closeResource(connection,null,null);
        }
        return list;
    }

    /**单元测试，查看功能是否正常
     * */
//    @Test
//    public void test(){
//        RoleService roleService = new RoleServiceImpl();
//        List<Role> list = roleService.getRoleList();
//        for(Role role:list){
//            System.out.println(role.toString());
//            System.out.println("============================");
//        }
//    }

}
